﻿@model smartcrm.Models.OrderList

<script src="../../Scripts/order.js"></script>
<div class="divSearch">
<form method="post" action="/Order/Index">
    <table>
        <tr>
            <td class="label">订单状态</td>
            <td>@Html.DropDownList("so", new SelectList(Model.DdlStatus, "ItemValue", "ItemText"))</td>
            <td class="label">支付状态</td>
            <td>@Html.DropDownList("ss", new SelectList(Model.DdlPaymentStatus, "ItemValue", "ItemText"))</td>
            <td class="label">客户</td>
            <td>@Html.DropDownList("sc", new SelectList(Model.DdlCustomer, "ItemValue", "ItemText"))
            <img onclick='SearchCustomer()' src="../../Images/grid/search.png" style="height:24px;width:24px; vertical-align:middle; cursor:pointer" title="快速搜索" />                  
            </td>
        </tr>
        <tr>         
            <td class="label">加工商</td>
            <td>@Html.DropDownList("sf", new SelectList(Model.DdlFactory, "ItemValue", "ItemText")) </td>         
            <td class="label">起始时间</td>
            <td>@Html.TextBox("sb", null, new { maxlength = "50", @title="双击清空"}) ~ @Html.TextBox("se", null, new { maxlength = "50", @title = "双击清空" })   </td>
            <td colspan="2"><input type="submit" id="btnSearch" value="搜索" /> </td> 
        </tr>
    </table>
   
</form>
</div>
@{
    smartcrm.Models.LoginUser user = Session["LoginUser"] as smartcrm.Models.LoginUser;
}

@if (user.PermissionList.Contains("P0202"))
{
<div class="FR"><input type="button" value="新增" id="btnNew" onclick="javascript:location.href='/Order/Create'" /> </div>
}
<div class="list">
<table id="tOrder">
<thead>
<tr>
<th style="width:100px">订单编号</th>
<th style="width:80px">交易日期</th>
<th>客户</th>
<th>订单名称</th>
<th style="width:70px">订单金额</th>
<th style="width:70px">已付金额</th>
<th style="width:70px">未付金额</th>
<th style="width:70px">加工费用</th>
<th style="width:65px">订单状态</th>
<th style="width:65px">支付状态</th>
<th style="width:100px">操作</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Orders)
        {
            <tr id="@item.OrderNo">
                <td>@Html.DisplayFor(modelItem => item.OrderNo)</td>
                <td>@item.TransactionDate.ToString("yyyy-MM-dd")</td>
                <td>@Html.DisplayFor(modelItem => item.CustomerShortName)</td>
                <td>@Html.DisplayFor(modelItem => item.OrderName)</td>               
                <td>@Html.DisplayFor(modelItem => item.Amount)</td>
                <td>@Html.DisplayFor(modelItem => item.Paid)</td>
                <td>@Html.DisplayFor(modelItem => item.Unpaid)</td>              
                <td>@Html.DisplayFor(modelItem => item.FactoryAmount)</td>  
                <td>@Html.DisplayFor(modelItem => item.StatusDescription)</td>  
                <td>@Html.DisplayFor(modelItem => item.PaymentStatusDescription)</td>              
                <td>
                @if (user.PermissionList.Contains("P0203"))
                {
                    <img src="../../Images/grid/edit.png" title="编辑" onclick="javascript:EditOrder('@item.OrderNo')" />  
                }
                @if (user.PermissionList.Contains("P0204"))
                {
                    <img src="../../Images/grid/delete.png" title="删除" onclick="javascript:DeleteOrder('@item.OrderNo')" />  
                }
                    <img src="../../Images/grid/detail.png" title="详细" onclick="javascript:ShowDetail('@item.OrderNo')" />  
                @if (user.PermissionList.Contains("P0205"))
                {
                    <img src="../../Images/grid/payment.png" title="支付" onclick="javascript:AddPayment('@item.OrderNo')" />  
                }
                </td>
            </tr>
        }
        <tr class="totalTd">
        <td><span style='color:yellow'>总计(所有页):</span></td>      
        <td></td>
        <td></td>
        <td></td>
        <td class="oderAmountTotal">@Model.TotalAmount</td>    
        <td class="oderAmountTotal">@Model.TotalPaid</td>    
        <td class="oderAmountTotal">@Model.TotalUnpaid</td>              
        <td class="oderAmountTotal">@Model.TotalFactoryAmount</td>     
        <td></td>    
        <td></td>
        <td></td> 
        </tr>
</tbody>
</table>
@Html.Pager("Index", "Order", Model.RouterDirectory, Model.PagerConfig, "pagerDiv", "pagerDiv", 8,true, false, true, true,false)
</div>

<div id="divDetail" title="订单详细信息" style="display:none">
    <div id="divDetailContent" class="list" style="overflow-y: auto; height: 550px;">    
    
        <div style="display:inline; float:left; margin-bottom:5px;"><span class="OrderStatus">订单状态：</span><span class="OrderStatus" id="dStatus"></span></div>         
        <div class="FR" style="margin-bottom:5px;"><span class="OrderStatus">支付状态：</span> <span id="dPaymentStatus"></span></div>          
        <table class="tableEdit">
            <tr>
                <td class="label">订单编号</td>
                <td id="dOrderNo"></td>
                <td class="label">订单名称</td>                
                <td id="dOrderName"></td>
            </tr>
            <tr>
                <td class="label">客户</td>
                <td id="dCustomer"></td>
                <td class="label">联系人</td>                
                <td id="dContact"></td>
            </tr>
            <tr>
                <td class="label">数量</td>
                <td id="dNumber"></td>
                <td class="label">预计完工</td>
                <td id="dExpectDeliveryDate"></td>                
            </tr>
            <tr>
                <td class="label">订单金额</td>
                <td id="dAmount"></td>
                <td class="label">已支付金额：</td>
                <td id="dPaid"></td>
            </tr>
            <tr>
                <td class="label">加工费</td>
                <td id="dFactoryAmount"></td>
                <td class="label">交易日期</td>
                <td id="dTransactionDate"></td>                
            </tr>
            <tr>
                <td class="label">创建者</td>
                <td id="dCreator"></td>
                <td class="label">创建时间</td>
                <td id="dCreatedTime"></td>
            </tr>
            <tr>
                <td class="label">备注</td>
                <td colspan="3" id="dMemo"></td>                
            </tr>
            <tr>
                <td class="label">自助查询URL</td>
                <td colspan="3" id="dQueryURL"></td>                
            </tr>
            <tr >
                <td class="label">明细</td>
                <td colspan="3" id="dDetail"></td>                
            </tr>
           
            <tr>
                <td class="label">修改历史</td>
                <td colspan="3" id="dHistory"></td>                
            </tr>
            <tr>
                <td class="label">支付记录</td>
                <td colspan="3" id="dPayment"></td>                
            </tr>
            <tr style="height:120px">
                <td class="label">流程</td>
                <td colspan="3" id='tdWorkFlow'>
                </td>
            </tr>
             <tr>
                <td class="label">附件</td>
                <td colspan="3" id='tdAttachment'>
                </td>
            </tr>
            <tr>
                <td class="label">备忘</td>
                <td colspan="3" class="list" >                   
                    <table style="width:100%" id="MemoPanel">
                        <thead>
                            <tr>
                                <th style="width:70%;">内容</th>
                                <th style="width:15%">添加者</th>
                                <th style="width:15%">时间</th>                                
                            </tr>  
                        </thead>
                        <tbody  id="dOrderMemo" >
                        
                        </tbody>                         
                    </table>      
                </td>
            </tr>            
        </table>

    </div>
    <div style="text-align:right;">      
       
       <input type="button" onclick="javascript:$('#divDetail').dialog('close');" value="关闭" />    
    </div>  
</div>

<div id="divPayment" title="订单支付信息" style="display:none">
    <div id="divPaymentContent" class="list" style="overflow-y: auto; height: 250px;">       
    <div id="unpaidDiv" style="display:inline; float:left; margin-bottom:5px;"><span class="OrderStatus">剩余未付金额：</span><span class="OrderStatusUnPaid" id="unpaidAmount"></span></div>
    <div id="paymentStatusDiv" class="FR" style="float:right;margin-bottom:5px;"><span class="OrderStatus">支付状态：</span> <span id="pdPaymentStatus"></span></div>  
    <div style="clear:both"></div>
        <div>
        <table class="tableEdit">
            <tr>
                <td class="label">支付记录</td>
                <td  colspan="3" id="PaymentHistory"></td>
            </tr>
            <tr >
                <td class="label">订单金额</td>
                <td class='money' id="Amount"></td>
                <td class="label">已支付金额</td>
                <td class='money' id="Paid"></td>
            </tr>
            <tr id="trAddPayment2">
                <td  class="label">支付金额</td>
                <td><input type="text" id="PaymentAmount" class="money" /><span class="redStar">*</span> </td>
                <td class="label">支付方式</td>                
                <td>
                    @Html.DropDownList("PaymentType", new SelectList(Model.DdlPaymentType, "ItemValue", "ItemText"), new { @style="width:100px;"})                    
                </td>
            </tr>
            <tr id="trAddPayment3">
                <td  class="label">备注</td>
                <td colspan="3"><input id="PaymentMemo" /></td>
                
            </tr>           
        </table>
        </div>
    </div>  

     <div style="text-align:right;">   
       <span id="errorMessagePayment" class="errorSpan"></span>     
       <input type="button" id="btnAddPayment" onclick="javascript:PaymentSubmit();" value="保存" />  
       <input type="button" onclick="javascript:$('#divPayment').dialog('close');" value="关闭" />    
    </div>  
</div>

<div id="divSearchCustomer" title="客户搜索" class="tableEdit" style="display:none">      
    <div style="overflow-y: auto; margin-top:20px;  text-align:center">  
        <input type="text" placeholder="请输入客户简称" id="txtCustomer" style="width:200px" />
    </div>
</div>
